package com.huawei.appgallery.forum.forum.card;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.forum.forum.bean.ForumListCardBeanV2;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import java.util.ArrayList;
import java.util.List;
import o.azb;
import o.bqx;
import o.bst;
import o.bun.b;
import o.bun.c;
import o.bun.e;
import o.bvf;
import o.cgz;
import o.cil;
import o.dof;
import o.epo;
import o.epv;
import o.epw;
import o.erq;
import o.zp;

public class ForumListCardV2 extends ForumCard {
    private View ʻ;
    private TextView ʻॱ;
    private ImageView ʼ;
    private ImageView ʽ;
    private TextView ˊ;
    private View ˊॱ;
    private View ˋ;
    private View ˋˋ;
    private ImageView ˋॱ;
    private ImageView ˋᐝ;
    private TextView ˌ;
    private TextView ˍ;
    private TextView ˎ;
    private ImageView ˎˎ;
    private ImageView ˎˏ;
    private ImageView ˏ;
    private Context ˏˎ;
    private TextView ˏˏ;
    private TextView ˏॱ;
    private ImageView ˑ;
    private TextView ͺ;
    private List<Section> ͺॱ = new ArrayList();
    private TextView ॱ;
    private ImageView ॱˊ;
    private ImageView ॱˋ;
    private TextView ॱˎ;
    private ImageView ॱॱ;
    private ImageView ॱᐝ;
    private TextView ᐝ;
    private TextView ᐝॱ;

    public class a implements OnClickListener {
        private int ˊ = 0;
        final /* synthetic */ ForumListCardV2 ˋ;

        public a(ForumListCardV2 forumListCardV2, int i) {
            this.ˋ = forumListCardV2;
            this.ˊ = i;
        }

        public void onClick(View view) {
            Section section = null;
            if (this.ˊ == 1) {
                if (this.ˋ.ͺॱ.size() >= 1) {
                    section = (Section) this.ˋ.ͺॱ.get(0);
                }
            } else if (this.ˊ == 2) {
                if (this.ˋ.ͺॱ.size() >= 2) {
                    section = (Section) this.ˋ.ͺॱ.get(1);
                }
            } else if (this.ˊ == 3) {
                if (this.ˋ.ͺॱ.size() >= 3) {
                    section = (Section) this.ˋ.ͺॱ.get(2);
                }
            } else if (this.ˊ == 4 && this.ˋ.ͺॱ.size() >= 4) {
                section = (Section) this.ˋ.ͺॱ.get(3);
            }
            if (section != null) {
                this.ˋ.ˊ(section, view);
            }
        }
    }

    public ForumListCardV2(Context context) {
        super(context);
        this.ˏˎ = context;
    }

    public cgz ˏ(View view) {
        ʽ(view);
        azb.ˏ(view, c.ᐝˊ);
        azb.ˏ(view, c.ˑ);
        azb.ˏ(view, c.ॱʼ);
        ॱ(view);
        return this;
    }

    private void ॱ(View view) {
        this.ʿ = (TextView) view.findViewById(c.ˎˎ);
        view.findViewById(c.ˌ).setVisibility(4);
        this.ˋ = view.findViewById(c.ʽॱ);
        this.ˏ = (ImageView) this.ˋ.findViewById(c.ᐧ);
        this.ˊ = (TextView) this.ˋ.findViewById(c.ᐝᐝ);
        this.ˎ = (TextView) this.ˋ.findViewById(c.ـ);
        this.ॱ = (TextView) this.ˋ.findViewById(c.ˏॱ);
        this.ʽ = (ImageView) this.ˋ.findViewById(c.ॱͺ);
        this.ॱॱ = (ImageView) this.ˋ.findViewById(c.ͺ);
        this.ʻ = view.findViewById(c.ˈ);
        this.ʼ = (ImageView) this.ʻ.findViewById(c.ᐧ);
        this.ᐝ = (TextView) this.ʻ.findViewById(c.ᐝᐝ);
        this.ˏॱ = (TextView) this.ʻ.findViewById(c.ـ);
        this.ͺ = (TextView) this.ʻ.findViewById(c.ˏॱ);
        this.ॱˊ = (ImageView) this.ʻ.findViewById(c.ॱͺ);
        this.ˋॱ = (ImageView) this.ʻ.findViewById(c.ͺ);
        this.ˊॱ = view.findViewById(c.ʿ);
        this.ॱᐝ = (ImageView) this.ˊॱ.findViewById(c.ᐧ);
        this.ʻॱ = (TextView) this.ˊॱ.findViewById(c.ᐝᐝ);
        this.ॱˎ = (TextView) this.ˊॱ.findViewById(c.ـ);
        this.ᐝॱ = (TextView) this.ˊॱ.findViewById(c.ˏॱ);
        this.ॱˋ = (ImageView) this.ˊॱ.findViewById(c.ॱͺ);
        this.ˋᐝ = (ImageView) this.ˊॱ.findViewById(c.ͺ);
        this.ˋˋ = view.findViewById(c.ʾ);
        this.ˎˎ = (ImageView) this.ˋˋ.findViewById(c.ᐧ);
        this.ˌ = (TextView) this.ˋˋ.findViewById(c.ᐝᐝ);
        this.ˍ = (TextView) this.ˋˋ.findViewById(c.ـ);
        this.ˏˏ = (TextView) this.ˋˋ.findViewById(c.ˏॱ);
        this.ˎˏ = (ImageView) this.ˋˋ.findViewById(c.ॱͺ);
        this.ˑ = (ImageView) this.ˋˋ.findViewById(c.ͺ);
        this.ˋ.findViewById(c.ˊˊ).setOnClickListener(new a(this, 1));
        this.ʻ.findViewById(c.ˊˊ).setOnClickListener(new a(this, 2));
        this.ˊॱ.findViewById(c.ˊˊ).setOnClickListener(new a(this, 3));
        this.ˋˋ.findViewById(c.ˊˊ).setOnClickListener(new a(this, 4));
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof ForumListCardBeanV2) {
            ForumListCardBeanV2 forumListCardBeanV2 = (ForumListCardBeanV2) cardBean;
            if (dof.ʽ(forumListCardBeanV2.v_())) {
                this.ʿ.setVisibility(4);
            } else {
                this.ʿ.setVisibility(0);
                this.ʿ.setText(forumListCardBeanV2.v_());
            }
            this.ͺॱ = forumListCardBeanV2.ˊ();
            if (this.ͺॱ != null) {
                ˎ();
            }
        }
    }

    private void ˎ() {
        if (this.ͺॱ.size() >= 1) {
            ˋ(1);
            ॱ((Section) this.ͺॱ.get(0), this.ˋ, this.ˊ, this.ˎ, this.ॱ, this.ʽ, this.ॱॱ, this.ˏ);
        }
        if (this.ͺॱ.size() >= 2) {
            ˋ(2);
            ॱ((Section) this.ͺॱ.get(1), this.ʻ, this.ᐝ, this.ˏॱ, this.ͺ, this.ॱˊ, this.ˋॱ, this.ʼ);
        }
        if (this.ͺॱ.size() >= 3) {
            ˋ(3);
            ॱ((Section) this.ͺॱ.get(2), this.ˊॱ, this.ʻॱ, this.ॱˎ, this.ᐝॱ, this.ॱˋ, this.ˋᐝ, this.ॱᐝ);
        }
        if (this.ͺॱ.size() >= 4) {
            ˋ(4);
            ॱ((Section) this.ͺॱ.get(3), this.ˋˋ, this.ˌ, this.ˍ, this.ˏˏ, this.ˎˏ, this.ˑ, this.ˎˎ);
        }
    }

    public void ˎ(BaseCardBean baseCardBean) {
        super.ˎ(baseCardBean);
    }

    private void ˋ(int i) {
        if (epv.ʼ(this.ˏˎ)) {
            if (i == 1 || i == 2) {
                this.ˋ.setVisibility(0);
                this.ʻ.setVisibility(0);
                return;
            }
            this.ˋ.setVisibility(0);
            this.ʻ.setVisibility(0);
            this.ˊॱ.setVisibility(0);
            this.ˋˋ.setVisibility(0);
        } else if (i == 1) {
            this.ˋ.setVisibility(0);
        } else if (i == 2) {
            this.ˋ.setVisibility(0);
            this.ʻ.setVisibility(0);
        } else if (i == 3) {
            this.ˋ.setVisibility(0);
            this.ʻ.setVisibility(0);
            this.ˊॱ.setVisibility(0);
        } else {
            this.ˋ.setVisibility(0);
            this.ʻ.setVisibility(0);
            this.ˊॱ.setVisibility(0);
            this.ˋˋ.setVisibility(0);
        }
    }

    private void ˊ(Section section, View view) {
        if (section != null && view != null) {
            View findViewById = view.findViewById(c.ˏॱ);
            if (findViewById instanceof TextView) {
                cil.ˋ(this.ˏˎ, new o.cim.a().ˊ(section.ॱॱ()).ˋ());
                bvf.ˋ().ˊ(this.ˏˎ, section, (TextView) findViewById);
            }
        }
    }

    private int ˊ(String str) {
        try {
            return Color.parseColor(str);
        } catch (Exception e) {
            bqx.ˋ("ForumListCardV2", "parse Color error:" + str);
            return -1;
        }
    }

    private void ˊ(int i, ImageView imageView, int i2) {
        int ˊ = erq.ˊ(i2, 0.6f);
        Drawable drawable = null;
        switch (i) {
            case 1:
                drawable = this.ˏˎ.getDrawable(b.ˋ);
                break;
            case 2:
                drawable = this.ˏˎ.getDrawable(b.ˎ);
                break;
        }
        if (drawable != null) {
            imageView.setImageDrawable(drawable);
            imageView.setBackground(epo.ॱ(drawable, ˊ));
        }
    }

    private void ॱ(Section section, View view, TextView textView, TextView textView2, TextView textView3, ImageView imageView, ImageView imageView2, ImageView imageView3) {
        String ʼ = section.ʼ();
        int ˊ = ˊ(ʼ);
        if (!TextUtils.isEmpty(ʼ)) {
            Drawable gradientDrawable = new GradientDrawable();
            gradientDrawable.setColor(ˊ);
            int i = 20;
            if (epw.ˏ()) {
                i = 60;
            }
            gradientDrawable.setAlpha(i);
            gradientDrawable.setCornerRadius(this.ˏˎ.getResources().getDimension(e.ˋ));
            view.setBackground(gradientDrawable);
            textView.setTextColor(ˊ);
            CharSequence ˏ = section.ˏ();
            if (TextUtils.isEmpty(ˏ)) {
                ˏ = "";
            }
            textView.setText(ˏ);
            textView2.setTextColor(ˊ);
            textView2.setText(bst.ॱ(this.ˏˎ, section.ˎ()));
            textView3.setTextColor(ˊ);
            textView3.setText(bst.ॱ(this.ˏˎ, (long) section.ʻ()));
            ˊ(1, imageView, ˊ);
            ˊ(2, imageView2, ˊ);
        }
        Glide.ˏ(this.ˏˎ).ˏ(section.ॱ()).ॱ((zp) ((zp) ((zp) ((zp) new zp().ˎ(b.ᐝ)).ˋ(b.ᐝ)).ˏ(b.ᐝ)).ͺ()).ˏ(imageView3);
    }
}
